<template>
    <div>
        <h2>用户登录</h2>
        <p>用户名：<input type="text" v-model="username"></p>
        <button @click="logint()">登录</button>    
    </div>    
</template>

<script>
import axios from "axios"
export default {
    name:"logint",
    data() {
        return {
            username:"",
        }
    },
    methods:{
        logint(){
            var data = {"username":this.username}
            axios({
                url:"http://127.0.0.1:8000/app04/login/",
                method:"get",
                params:data
            }).then(res=>{
                if(res.data.code==200){
                    sessionStorage.setItem("username",res.data.data)
                    console.log(res.data)
                }else{
                    alert("失败")
                }
            })
        }
    }
}
</script>

<style>

</style>
